/**
 * Created by yeyingpc on 2017/6/7.
 */
import React, { Component } from 'react';
import { Text, TouchableOpacity, StyleSheet, Image, View, ListView } from 'react-native';
import color from '../common/Color';
import screen from '../common/screen';
import NavigationItem from '../widget/NavigationItem';
import RefreshListView from '../widget/RefreshListView';

class HomeScene extends Component {
    static navigationOptions = ({ navigation }) => ({
        headerTitle: (
            <TouchableOpacity style={styles.searchBar}>
                <Image source={require('../img/Home/search_icon.png')} style={styles.searchIcon} />
            </TouchableOpacity>
        ),
        headerRight: (
            <NavigationItem
                icon={require('../img/Home/icon_navigationItem_message_white@2x.png')}
                onPress={() => {console.log('pressed')}}
            />
        ),
        headerLeft: (
            <NavigationItem
                title="成都"
                titleStyle={{ color: '#ffffff' }}
                onPress={() => {console.log('pressed')}}
            />
        ),
        headerStyle: { backgroundColor: color.theme },
    });
    constructor(props) {
        super(props);
        let ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2});
        this.state = {
            discounts: [],
            dataSource: ds.cloneWithRows([])
        }
    }
    renderHeader = () => {
        return (
            <View>
                <Text>header测试</Text>
            </View>
        )
    };
    render() {
        return (
            <View style={[styles.container]}>
                <RefreshListView
                    ref="listView"
                    dataSource={this.state.dataSource}
                    renderHeader={() => this.renderHeader()}
                />
            </View>
        )
    }
}



// define your styles
const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: color.background
    },
    recommendHeader: {
        height: 35,
        justifyContent: 'center',
        borderWidth: screen.onePixel,
        borderColor: color.border,
        paddingVertical: 8,
        paddingLeft: 20,
        backgroundColor: 'white'
    },
    searchBar: {
        width: screen.width * 0.7,
        height: 30,
        borderRadius: 19,
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: 'white',
        alignSelf: 'center',
    },
    searchIcon: {
        width: 20,
        height: 20,
        margin: 5,
    }
});

export default HomeScene;
